use Flap qw/-m -s -w/;

sub{
    my($self, $sch) = @_;
    my $t = $sch->table;
    my @sql;
    foreach($sch->relations){
        my $ri = $sch->relation_info($_);
        next if $ri->{type} ne 'belongs_to';
        push @sql, "CONSTRAINT $t\_fk_$_ FOREIGN KEY (".
            join(', ', map{ $_->[1] ? $_->[1] : () } @{$ri->{fk}}).
            ') REFERENCES '.$ri->{schema}->table.' ('.
            join(', ', map{ $_->[0] } @{$ri->{fk}}).
            ')';
    }
    
    push @sql, "CONSTRAINT $_" for @{$sch->constraints || []};
    @sql;
};
